﻿using System;
using System.Collections.Generic;

namespace WindowsFormsApplication1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            string refererUrl = "\ Your URL or null";
            string apiKey = "\ Zeo API key";
            string username = "\ username to get information for";
            string password = "\ password for user profile";

            try
            {
                using (Zeo.ZeoApi api = Zeo.ZeoApi.ConnectHttpBasicAuthentication(apiKey, username, password))
                {
                    api.RefererUrl = refererUrl;
                    api.DebugTrace = true;

                    System.Diagnostics.Trace.WriteLine("GetOverallAverageZQScore=" + api.GetOverallAverageZQScore().ToString());
                    System.Diagnostics.Trace.WriteLine("GetOverallAverageDayFeelScore=" + api.GetOverallAverageDayFeelScore().ToString());
                    System.Diagnostics.Trace.WriteLine("GetOverallAverageMorningFeelScore=" + api.GetOverallAverageMorningFeelScore().ToString());
                    System.Diagnostics.Trace.WriteLine("GetOverallAverageSleepStealerScore=" + api.GetOverallAverageSleepStealerScore().ToString());

                    IList<DateTime> allDates = api.GetAllDatesWithSleepData();
                    IList<DateTime> allDatesRange = api.GetDatesWithSleepDataInRange(null, null);
                    IList<DateTime> datesInLastWeek = api.GetDatesWithSleepDataInRange(DateTime.Today.AddDays(-7), null);
                    IList<DateTime> datesBeforeLastWeek = api.GetDatesWithSleepDataInRange(null, DateTime.Today.AddDays(-7));
                    IList<DateTime> datesTwoWeeksAgo = api.GetDatesWithSleepDataInRange(DateTime.Today.AddDays(-14), DateTime.Today.AddDays(-7));

                    if (allDates.Count > 0)
                    {
                        Zeo.SleepStats firstStats = api.GetSleepRecordForDate(allDates[0]);
                    }
                    Zeo.SleepStats todaysStats = api.GetSleepStatsForDate(DateTime.Today);
                }
            }
            catch (Zeo.ZeoApi.ApiException apiException)
            {
                System.Diagnostics.Trace.WriteLine("ApiException. Status: " + apiException.Status.ToString() + ", Msg: " + apiException.ErrorMessage);
            }
            catch (System.Net.WebException webException)
            {
                System.Diagnostics.Trace.WriteLine("WebException. Status " + webException.Status.ToString() + ", Msg: " + webException.Message);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Trace.WriteLine("Exception. Msg: " + exception.Message);
            }
        }
    }
}
